/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Observable;
import java.util.Observer;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Jason Sorbello
 */
public class StartServer extends Thread {

    private boolean running = false;
    private ServerSocket flightServerSocket;
    private static final int SOCKET_NUMBER = 3120;

    public StartServer() {

    }

    public boolean checkRunning() {
        if (!running) {
            running = true;
            return false;
        } else {
            return running;
        }
    }

    public void newServerSocket() {
        try {
            flightServerSocket = new ServerSocket(SOCKET_NUMBER);
            // FlightServer server = new FlightServer();
            // server.start();
        } catch (IOException ex) {
            Logger.getLogger(StartServer.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void newThread() {
//        Thread a = new Thread();
//        while (true) {
//            try {
//                Socket client = flightServerSocket.accept();
//                Connect connection = new Connect(client);
//            } catch (Exception ex) {
//                ex.printStackTrace();
//            }
//        }
        Connect q = new Connect(flightServerSocket);
    }

    public void update(Observable o, Object arg) {
        
    }


    /* if
    (!running) {
    running = true;
    try {
    FlightServer server = new FlightServer();
    server.start();
    text.append("Server Started\n");
    } catch (Exception ea) {
    }
    }
    else


    {
    text.append("There is already a server instance running\n");
    }
     */
}
